<?php

    global $mikron;

    $pageindex = 4;
    $pacientcode = isset($_GET['code'])?$_GET['code']:"";
    $patientid = isset($_GET['patientid'])?$_GET['patientid']:"";
    $postid = isset($_GET['speccode'])?$_GET['speccode']:"";
    $prevpage = "page3.php";
    $nextpage = "";
    $errorpage = $prevpage;

    if(isset($_SESSION['form']))
    {$_SESSION['form'] = null;}
    
    $dirlist_for_month = isset($_REQUEST['month'])?(int)$_REQUEST['month']:(int)date('m', time());
    $dirlist_for_year = isset($_REQUEST['year'])?(int)$_REQUEST['year']:(int)date('Y', time());

    if(isset($_REQUEST['deleteremotedirection']))
    {
        $xml = CreateDeleteRemoteDirectionXML($_REQUEST['deleteremotedirection']);
        /*?><textarea cols="128" rows="4">
        <?php echo $xml;?>
        </textarea><?php */
        CallSoap("deleteremotedirection", $xml);
        header("Location: /remoterecord/");
        exit;
    }
    
        /* ?><p>Запись проведена успешно.</p><?php */
        require_once(dirname(__FILE__).'/remotedirectionslist.inc');
        $record->getdata($dirlist_for_month, $dirlist_for_year);
        
        ?>
        <TABLE width="100%">
            <tr>
                <td>
                    <font class="big_text_green">
                    Список направлений:
                    </font>
                </td>
                <td align="right">
                    <!-- -span style="p osition: absolute; top: 4px;"><img src="<?php echo constant('SM_TEMPLATE_WWW');?>images/remoterecord/add.ico"></span --><a href="index.php">Записать пациента</a>
                </td>
            </tr>
        </TABLE>
        
        <TABLE class="wintable" border="0" width="100%" cellspacing="0">
            <TR>
            <TD class="wincap1">Номер направления</TD>
            <TD class="wincap2">Дата направления</TD>
            <TD class="wincap2">Пациент</TD>
            <TD class="wincap2">Дата рождения</TD>
			<TD class="wincap2">Пол</TD>
            <TD class="wincap2">Документ</TD>
            <TD class="wincap2">Полис ОМС</TD>
            <TD class="wincap2">&nbsp;</TD>
            </TR>        
            <?php
            foreach($record->directions as $direction)
            {
                /*
                номер
                дата
                фио
                полис
                дата рождения
                */
                ?>
                <TR class="hvr">
                <TD class="wincell1"><font class="small_text"><?php echo $direction->number;?><font></TD>   
                <TD class="wincell2"><font class="small_text"><?php echo $direction->date;?><font></TD>   
                <TD class="wincell2"><font class="small_text"><a href="print_preview.php?okremotedirection=<?php echo $direction->guid;?>"><?php echo $direction->patient->fio;?></a><font></TD>   
                <TD class="wincell2"><font class="small_text"><?php echo $direction->patient->birthday;?><font></TD>   
                <TD class="wincell2"><font class="small_text"><?php echo substr($direction->patient->sex, 0, 1);?><font></TD> 
				<TD class="wincell2"><font class="small_text"><?php echo $direction->patient->document;?><font></TD>
                <TD class="wincell2"><font class="small_text"><?php echo $direction->patient->policy;?><font></TD>
                <TD class="wincell2">
                    <!-- a href="print_preview.php?okremotedirection=<?php echo $direction->guid;?>">Просмотр</a> — -->
                    <a onclick="return userquery2('Вы действительно хотите удалить направление?');" href="/remoterecord/?deleteremotedirection=<?php echo $direction->guid;?>">Удалить</a>
                </TD>
                </TR>
                <?php
            }
            ?>
        </TABLE>
        
        <script type="text/javascript">
            function userquery(text)
            {
                return userquery2(text);
            }
        </script>
        <script language="VBScript">
            function userquery2(text)
                userquery2 =msgbox(text,4)=6
            end function
        </script>
        
        <FORM action="" method="get">
        <table width="100%">
            <tr>
            <td><a href="index.php">Записать пациента</a></td>
            <td align="right">
                <select name="month" onchange="this.form.submit();">
                    <option value="1">Январь</option>
                    <option value="2">Февраль</option>
                    <option value="3">Март</option>
                    <option value="4">Апрель</option>
                    <option value="5">Май</option>
                    <option value="6">Июнь</option>
                    <option value="7">Июль</option>
                    <option value="8">Август</option>
                    <option value="9">Сентябрь</option>
                    <option value="10">Октябрь</option>
                    <option value="11">Ноябрь</option>
                    <option value="12">Декабрь</option>
                </select>
                <select name="year" onchange="this.form.submit();">
                    <option value="2008">2008</option>
                    <option value="2009">2009</option>
                    <option value="2010">2010</option>
                </select>
            </td>
            </tr>
        </table>
        </FORM>
        
        <script type="text/javascript">
            setValue('month', <?php echo $dirlist_for_month; ?>);
            setValue('year', <?php echo $dirlist_for_year; ?>);
        </script>

        <?php

    $mikron->Page->EndBody();

?>